/*****************************************************************************
 * $Workfile:: electric2.c                                                   $
 * $Revision:: 19                                                            $
 * $JustDate::  3/21/12                                                      $
 *
 *      GENIE V ECU
 *      run-about parameters
 *****************************************************************************/

#include "common.h"
#include "curve.h"
#include "nvm.h"

// RUN_ABOUT parameter definition

#define LIFT_TYPE                       ELEC2              // lift type
#define MAGIC_ID                        ELEC2_REV      // magic id

#define BRAKE_APPLY_DELAY               MILLISECONDS(600)
#define COIL_FAULT_DETECTION_PERIOD     MILLISECONDS(700)
#define NEUTRAL_ZONE_STEERING_OFF_DELAY MILLISECONDS(750)
#define DRIVE_DIRECTION_SWITCH_DELAY    MILLISECONDS(40)
#define MOTOR_ENABLE_DELAY              MILLISECONDS(80)
#define OVERLOAD_STABILIZATION_PERIOD   MILLISECONDS(2000)

#define DRIVE_STEERING_BOOST_PWM        PERCENT(0)
#define NEUTRAL_ZONE_STEERING_PWM       PERCENT(70)
#define CHASSIS_LIFT_UP_PWM             PERCENT(0)
#define PLATFROM_LIFT_UP_MAX_PWM        PERCENT(75)
#define JOYSTICK_OFFSET_COMPENSATION    COUNTS(50)
#define JOYSTICK_NEUTRAL_ZONE           COUNTS(20)

#define BATTERY_LEVEL1                  VOLTS_X_10(178)
#define BATTERY_LEVEL2                  VOLTS_X_10(197)
#define BATTERY_LEVEL3                  VOLTS_X_10(207)
#define BATTERY_LEVEL4                  VOLTS_X_10(216)
#define BATTERY_LEVEL5                  VOLTS_X_10(226)

#define TILT_BRAKE_DELAY              MILLISECONDS(0)
#define LEVEL_BRAKE_DELAY               MILLISECONDS(0)

#define SPARE0                          0
#define SPARE1                          0
#define SPARE2                          0
#define SPARE3                          15
#define SPARE4                          0

// drive curve (fast
#define FAST_INDEX1                     COUNTS(5)
#define FAST_INDEX2                     COUNTS(30)
#define FAST_INDEX3                     COUNTS(60)
#define FAST_INDEX4                     COUNTS(95)
#define FAST_PWMPOS1                    PERCENT(6)
#define FAST_PWMPOS2                    PERCENT(13)
#define FAST_PWMPOS3                    PERCENT(36)
#define FAST_PWMPOS4                    PERCENT(64)
#define FAST_PWMPOS_MAX                 PERCENT(100)
#define FAST_PWMPOS_ADJUST              PERCENT(100)
#define FAST_PWMNEG1                    PERCENT(6)
#define FAST_PWMNEG2                    PERCENT(13)
#define FAST_PWMNEG3                    PERCENT(36)
#define FAST_PWMNEG4                    PERCENT(64)
#define FAST_PWMNEG_MAX                 PERCENT(100)
#define FAST_PWMNEG_ADJUST              PERCENT(100)
#define FAST_ACCEL_INCREMENT            COUNTS(25)
#define FAST_DECEL_INCREMENT            COUNTS(2)
#define FAST_PERIOD                     MILLISECONDS(10)


// drive curve (elevated
#define RISED_INDEX1                     COUNTS(1)
#define RISED_INDEX2                     COUNTS(30)
#define RISED_INDEX3                     COUNTS(60)
#define RISED_INDEX4                     COUNTS(95)
#define RISED_PWMPOS1                    PERCENT(6)
#define RISED_PWMPOS2                    PERCENT(10)
#define RISED_PWMPOS3                    PERCENT(17)
#define RISED_PWMPOS4                    PERCENT(27)
#define RISED_PWMPOS_MAX                 PERCENT(35)
#define RISED_PWMPOS_ADJUST              PERCENT(35)
#define RISED_PWMNEG1                    PERCENT(6)
#define RISED_PWMNEG2                    PERCENT(10)
#define RISED_PWMNEG3                    PERCENT(17)
#define RISED_PWMNEG4                    PERCENT(27)
#define RISED_PWMNEG_MAX                 PERCENT(35)
#define RISED_PWMNEG_ADJUST              PERCENT(35)
#define RISED_ACCEL_INCREMENT            COUNTS(1)
#define RISED_DECEL_INCREMENT            COUNTS(2)
#define RISED_PERIOD                     MILLISECONDS(25)

// lift up curve (fast no parallel coil
#define LIFT_INDEX1                     COUNTS(1)
#define LIFT_INDEX2                     COUNTS(25)
#define LIFT_INDEX3                     COUNTS(45)
#define LIFT_INDEX4                     COUNTS(75)
#define LIFT_PWMPOS1                    PERCENT(12)
#define LIFT_PWMPOS2                    PERCENT(25)
#define LIFT_PWMPOS3                    PERCENT(36)
#define LIFT_PWMPOS4                    PERCENT(53)
#define LIFT_PWMPOS_MAX                 PERCENT(75)
#define LIFT_PWMPOS_ADJUST              PERCENT(75)
#define LIFT_PWMNEG1                    PERCENT(0)
#define LIFT_PWMNEG2                    PERCENT(0)
#define LIFT_PWMNEG3                    PERCENT(0)
#define LIFT_PWMNEG4                    PERCENT(0)
#define LIFT_PWMNEG_MAX                 PERCENT(0)
#define LIFT_PWMNEG_ADJUST              PERCENT(0)
#define LIFT_ACCEL_INCREMENT            COUNTS(2)
#define LIFT_DECEL_INCREMENT            COUNTS(20)
#define LIFT_PERIOD                     MILLISECONDS(15)

// drive curve (slow
#define SLOW_INDEX1                     COUNTS(1)
#define SLOW_INDEX2                     COUNTS(30)
#define SLOW_INDEX3                     COUNTS(60)
#define SLOW_INDEX4                     COUNTS(95)
#define SLOW_PWMPOS1                    PERCENT(10)
#define SLOW_PWMPOS2                    PERCENT(15)
#define SLOW_PWMPOS3                    PERCENT(25)
#define SLOW_PWMPOS4                    PERCENT(41)
#define SLOW_PWMPOS_MAX                 PERCENT(50)
#define SLOW_PWMPOS_ADJUST              PERCENT(50)
#define SLOW_PWMNEG1                    PERCENT(10)
#define SLOW_PWMNEG2                    PERCENT(15)
#define SLOW_PWMNEG3                    PERCENT(25)
#define SLOW_PWMNEG4                    PERCENT(41)
#define SLOW_PWMNEG_MAX                 PERCENT(50)
#define SLOW_PWMNEG_ADJUST              PERCENT(50)
#define SLOW_ACCEL_INCREMENT            COUNTS(2)
#define SLOW_DECEL_INCREMENT            COUNTS(2)
#define SLOW_PERIOD                     MILLISECONDS(25)


// steer curve (elevated
#define STEER_UP_INDEX1                     COUNTS(1)
#define STEER_UP_INDEX2                     COUNTS(30)
#define STEER_UP_INDEX3                     COUNTS(60)
#define STEER_UP_INDEX4                     COUNTS(100)
#define STEER_UP_PWMPOS1                    PERCENT(2)
#define STEER_UP_PWMPOS2                    PERCENT(8)
#define STEER_UP_PWMPOS3                    PERCENT(12)
#define STEER_UP_PWMPOS4                    PERCENT(17)
#define STEER_UP_PWMPOS_MAX                 PERCENT(18)
#define STEER_UP_PWMPOS_ADJUST              PERCENT(18)
#define STEER_UP_PWMNEG1                    PERCENT(2)
#define STEER_UP_PWMNEG2                    PERCENT(8)
#define STEER_UP_PWMNEG3                    PERCENT(12)
#define STEER_UP_PWMNEG4                    PERCENT(17)
#define STEER_UP_PWMNEG_MAX                 PERCENT(18)
#define STEER_UP_PWMNEG_ADJUST              PERCENT(18)
#define STEER_UP_ACCEL_INCREMENT            COUNTS(50)
#define STEER_UP_DECEL_INCREMENT            COUNTS(20)
#define STEER_UP_PERIOD                     MILLISECONDS(15)

/*
 * it checks for parameter boundaries
 */
#include "c_check_lift_setup.h"

extern const struct nvm_lift_setup electric2_setup =
{
#include "lift_setup.h"
};

